define(function(require, exports, module) {

  var Backbone = require('backbone');
  var $ = require('jquery');
  var _ = require('underscore');
  var jsonview = require('jsonview');
  var tmpl = require('text!../tmpl.html');

  function main() {
    var $app = $('<div id="app">');
    $('#main').html($app);

    $app.append(tmpl);

    var canvas = document.getElementById("canvas")
    var context = canvas.getContext("2d")

    setInterval(function() {
      draw()
      update()
    }, 10)

    function drawLine() {
      context.beginPath()
      context.moveTo(0, 100)
      context.lineTo(500, 768)

      context.strokeStyle = "#0080ff"
      context.lineWidth = 5
      context.stroke()
    }

    var currentPosition = {
      x: 100,
      y: 100
    }

    function draw() {
      context.clearRect(0, 0, 1024, 768);

      drawLine()
      context.beginPath()
      context.arc(currentPosition.x, currentPosition.y, 80, 0, 2 * Math.PI)
      context.closePath()
      context.fillStyle = "#ff0080"
      context.fill()
    }

    function update() {
      currentPosition.x += 5
      currentPosition.y += 6.7
    }
  }
  
  return main;
})
